<?php


namespace App\Model;


/**
 * App\Model\AddressCopy
 *
 * @property int $id
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property int $user_id 地址所有者
 * @property string $name 收货人
 * @property string $phone 手机号
 * @property string $address 地址
 * @property string $address_index 表单选中下标
 * @property string $address_detail 详细地址
 * @property string $label 标签
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\AddressCopy newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\AddressCopy newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\AddressCopy query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\AddressCopy whereAddress($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\AddressCopy whereAddressDetail($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\AddressCopy whereAddressIndex($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\AddressCopy whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\AddressCopy whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\AddressCopy whereLabel($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\AddressCopy whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\AddressCopy wherePhone($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\AddressCopy whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Model\AddressCopy whereUserId($value)
 * @mixin \Eloquent
 */
class AddressCopy extends Base
{

    protected $table='address_copy';

    protected $fillable=['user_id','name','phone','address','address_index','address_detail','label'];


    function setAddressIndexAttribute($value)
    {

        if(!$value) return $this->attributes['address_index']='';

        if(!is_array($value)) return $this->attributes['address_index']='';


        $this->attributes['address_index']=join(',',$value);

    }


    function getAddressIndexAttribute($value){

        if(!$value) return [];

        return explode(',',$value);

    }

}
